The Tab View Component > Using the Tab View component > Creating an application with the Tab View component |
Creating an application with the Tab View component
The following procedure describes how to use the Tab View component. In this procedure, you enter simple ActionScript code to that adds 3 sections to the Tab View. For more complex examples, see Examples for the Tab View component.
To create a simple application using the Tab View component:
1 |
Open Macromedia Flash MX. |
2 |
Open the Components panel (Window > Components). |
3 |
Select Flash UI Components Set 5 from the Components panel menu. |
4 |
Drag an instance of the Tab View component onto the stage. |
5 |
Set the instance name of the Tab View to myTab_tbv. |
6 |
Add a new layer to the main timeline and name it actions. |
7 |
Select the new layer and open the Actions panel (Window > Actions). |
8 |
In the Actions panel add the following code: |
//remove the preset tabs
myTab_tbv.removeAll();
//add three new tabs
myTab_tbv.addItem("Tab1");
myTab_tbv.addItem("Tab2");
myTab_tbv.addItem("Tab3");
//create a listener object to list for events from the component.
var listener = new Object();
//create the onSelect method which is called when a tab is selected
listener.onSelect = function(oldIndex, newIndex, componentRef)
{
trace("Tab Selected : " + myTab_tbv.getItemAt(newIndex).label);
}
//add the listener to the tab
myTab_tbv.addListener(listener); |
|
9 |
Save, publish, and test the movie. There will be an Tab View component with 3 components. When you change tabs a message will trace in the output window, specifying which tab was selected. |
You can view the code for this example in the tab_simple_example.fla example file.